import pytest
from data.read_data import read_ihrmUpdate
from scripts.hm02_api import IhrmLoginApi, IhrmUpdateApi
from scripts.hm03_assert import IhrmUpdate


class TestIhrmSearch:
    @pytest.mark.parametrize("emp_id, username, state_code, success, code, message", read_ihrmUpdate())
    def test(self, emp_id, username, state_code, success, code, message):
        # 登录
        login_data = {"mobile": "13800000002", "password": "123456"}
        login_result = IhrmLoginApi.login(login_data)
        token = login_result.json()["data"]
        # 修改员工
        update_date = {"username": username}
        update_result = IhrmUpdateApi.update(emp_id, token, update_date)
        # print(update_result.json())
        IhrmUpdate.update_assert(update_result, state_code, success, code, message)
